﻿
using System;
using System.Xml;

namespace HuaXingSDK.Response
{
    public class Res还款收益查询 : HXSyncResponse
    {
        public Res还款收益查询Status Return_Status { get; private set; }
        public HXDFFlag DFFlag { get; private set; }
        public string LoanNo { get; private set; }
        public string BWACName { get; private set; }
        public string BWACNo { get; private set; }
        public string TotalNum { get; private set; }
        public RSItem[] RSList { get; private set; }

        public Res还款收益查询(string outerXml) : base(outerXml)
        {
            RSList = new RSItem[0];
        }

        protected override object GetValue(Type propertyType, XmlNode node)
        {
            if (propertyType == typeof(Res还款收益查询Status))
            {
                if (node.InnerText.Trim().Length != 1)
                    throw new HXException($"{nameof(Return_Status)}的内容格式不正确。");
                return (Res还款收益查询Status) node.InnerText.Trim()[0];
            }
            return base.GetValue(propertyType, node);
        }

        public class RSItem : XmlToEntity
        {
            public string SubseqNo { get; private set; }
            public string ACNo { get; private set; }
            public string ACName { get; private set; }
            public int IncomeDate { get; private set; }
            public decimal Amount { get; private set; }
            public decimal? PrincipalAMT { get; set; }
            public decimal? IncomeAMT { get; set; }
            public decimal? FeeAMT { get; set; }
            public RSItemStatus Status { get; private set; }
            public string ErrMsg { get; private set; }
            public int HostDT { get; private set; }
            public string HostJNLno { get; private set; }

            protected internal RSItem(string outerXml) : base(outerXml)
            {

            }

            protected override object GetValue(Type propertyType, XmlNode node)
            {
                if (propertyType == typeof(RSItemStatus))
                {
                    if (node.InnerText.Trim().Length != 1)
                        throw new HXException($"{nameof(Status)}的内容格式不正确。");
                    return (RSItemStatus)node.InnerText.Trim()[0];
                }
                return base.GetValue(propertyType, node);
            }

            public enum RSItemStatus
            {
                待处理 = 'L',
                正在处理 = 'R',
                未知 = 'N',
                成功 = 'S',
                失败 = 'F'
            }
        }

        public enum Res还款收益查询Status
        {
            处理中 = 'L',
            失败 = 'F',
            成功 = 'S'
        }
    }
}
